package vn.com.fsoft.action;

import java.util.List;

import vn.com.fsoft.business.impl.GovOfficeRegionBusiness;
import vn.com.fsoft.model.entities.GovOfficeRegion;

import com.opensymphony.xwork2.ActionSupport;

public class GovOfficeRegionAction extends ActionSupport{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private List<GovOfficeRegion> allGov;
	private int page = 1;
	private static int recordPerPage = 1;
	private int currentPage;
	private static int totalPage;
	
	


	public int getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}

	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}

	public List<GovOfficeRegion> getAllGov() {
		return allGov;
	}

	public void setAllGov(List<GovOfficeRegion> allGov) {
		this.allGov = allGov;
	}

	public String getAllGovOffice(){
		GovOfficeRegionBusiness govOfficeRegionBusiness = new GovOfficeRegionBusiness();
		
		System.out.println("total page:" + totalPage);
		System.out.println("page:" + page);
		System.out.println("curent page:" + currentPage);
		if(page==0){
			setPage(1);
		}
		if(page>totalPage){
			setPage(totalPage);
		}
		this.setCurrentPage(page);
		allGov = govOfficeRegionBusiness.getAllGovOffice(page, recordPerPage);
		totalPage = GovOfficeRegionBusiness.getTotalPage();
		return "success";
	}

	public int getRecordPerPage() {
		return recordPerPage;
	}

	public void setRecordPerPage(int recordPerPage) {
		GovOfficeRegionAction.recordPerPage = recordPerPage;
	}

	public int getTotalPage() {
		return totalPage;
	}

	public void setTotalPage(int totalPage) {
		GovOfficeRegionAction.totalPage = totalPage;
	}
}
